package football.haha.com.footballtv.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;

import butterknife.Bind;
import butterknife.ButterKnife;
import football.haha.com.footballtv.R;
import football.haha.com.footballtv.utils.ActivityUtils;

/**
 * Created by haha on 2017/10/7.
 */

public class MyPackageActivity extends BaseActivity {

    @Bind(R.id.fl_main)
    FrameLayout flMain;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_package);
        ButterKnife.bind(this);

        createOnlyBorderView(flMain);
        scale = 1.05f;
        borderView.setBorderBitmapResId(R.drawable.focus_quare, (int) getResources().getDimension(R.dimen.px110),
                (int) getResources().getDimension(R.dimen.px60));
        addPackage();
    }

    private void addPackage() {
        for (int i = 0; i < 4; i++) {
            View itemFootball = View.inflate(this, R.layout.item_package, null);
            itemFootball.setOnClickListener(this);
            itemFootball.setOnFocusChangeListener(this);
            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams((int) getResources().getDimension(R.dimen.px830),
                    (int) getResources().getDimension(R.dimen.px240));

            int topMargin = (int) getResources().getDimension(R.dimen.px170) + i % 2 * (int) getResources().getDimension(R.dimen.px280);
            int leftMargin = (int) getResources().getDimension(R.dimen.px100) + i / 2 * (int) getResources().getDimension(R.dimen.px870);

            params.topMargin = topMargin;
            params.leftMargin = leftMargin;

            flMain.addView(itemFootball, params);

        }
    }

    @Override
    public void onClick(View view) {
        super.onClick(view);
        ActivityUtils.gotoActivity(this, BuyMealActivity.class);
    }
}
